#include <iostream>
#include <string>
#include <map>

using namespace std;

int sget[128];
map<string, bool> M[4];
map<int, string> tos;
static int N = []() {
    sget['I'] = 1;
    sget['N'] = 2;
    sget['G'] = 3;
    tos[0] = "W";
    tos[1] = "I";
    tos[2] = "N";
    tos[3] = "G";
    return 205;
}();

string sin;
int dp[4][205];
signed main() {
    int w, I, n, g;
    cin >> w >> I >> n >> g;
    for (int i = 1; i <= w; ++ i) cin >> sin, M[0][sin] = true;
    for (int i = 1; i <= I; ++ i) cin >> sin, M[1][sin] = true;
    for (int i = 1; i <= n; ++ i) cin >> sin, M[2][sin] = true;
    for (int i = 1; i <= g; ++ i) cin >> sin, M[3][sin] = true;
    cin >> sin;
    dp[sget[sin[0]]][0] = 1;
    for (int i = 1; i < sin.size(); ++i) {
        for (int j = 0; j < 4; ++j) {
            if (dp[j][i - 1]) {
                string from = tos[j] + sin[i];
                for (int k = 0; k < 4; ++k) {
                    if (M[k][from]) 
                        dp[k][i]++;
                }
            }
        }
    }
    bool flag = true;
    for (int i = 0; i < 4; i++) {
        if (dp[i][sin.size() - 1]) {
            flag = false;
            cout << tos[i];
        }
    }
    if (flag) cout << "The name is wrong!";
    return 0;
}